<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>这里将显示您按下键的CODE</h1>
</body>
<script>
    let h1 = document.querySelector('h1');
    let ht = document.querySelector('html')
    ht.onkeydown = function (e) {
        h1.innerText = e.keyCode
    }
</script>

</html>